var Post=require('../lib/mongo.js').Post;

module.exports={
    create:post=>new Post(post).save(),

    getPostById:postId=>Post.findOne({_id:postId}),

    getPosts:author=>{
       var query={};
       if(author){
           query.author=author;
       }
       return Post.find(query,null,{sort:{createTime:-1}});
    }
};